#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
using namespace std;
int main() {
	string st1;
	string st2;
	int max = 0;
	cin >> st1 >> st2;
	auto it1 = st1.begin();
	auto it1_poi = st1.begin();
	auto it2 = st2.begin();
	while (it1 != st1.end()) {
		int count = 0;
		while (it1 != st1.end() && it2 != st2.end() && *it1 == *it2) {
			count++;
			it1++;
			it2++;
		}
		if (count > max)
			max = count;
		it1 = it1_poi;
		while (*it2 != *it1 && it2 != st2.end()) {
			it2++;
		}
		if (it2 == st2.end())
		{
			it2 = st2.begin();
			it1++;
			it1_poi++;
		}
	}
	cout << max << endl;
}
